import 'package:shelf/shelf.dart';
import 'package:shelf_router/shelf_router.dart';
import 'package:xsdk_flutter/xsdk/utils/webserver/support/x_restful_api_router.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_date.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_response.dart';

/*
RESTFul风格,具有一组相同url前缀的api
使用命令自动生成Router: flutter pub run build_runner build --delete-conflicting-outputs

dev_dependencies:
  build_runner: ^2.4.8
  shelf_router_generator: ^1.1.0

 */
part 'x_demo_restful_api_router_system.g.dart';

class XDemoRESTFulApiRouter_system extends XRESTFulApiRouter{

  XDemoRESTFulApiRouter_system():super(urlPrefixPath:'/system');

  //自定义路由
  @Route.post('/date')
  Future<Response> getSystemDateTimeMS(Request request) async {
    String response=XResponseUtils.responseBodyJson(code: '200', message: 'ok',data: XDateUtils.getCurrentTime_ms());
    return Response.ok(response,headers: XResponseUtils.responseHeaders());
  }

  //
  @override
  Router get router => _$XDemoRESTFulApiRouter_systemRouter(this);

}


